package io.gitee.yth.design.pattern.test.core.pattern.creational.singleton;

/**
 * 2) 饿汉式（静态代码块）
 * <p>
 * 优缺点和第一种方式一样
 * <p>
 * 但是这种方式可以处理更复杂的类创建逻辑
 *
 * @author yth
 * @since 2023-04-16-20:10
 */
public class Singleton2 {

    private static Singleton2 instance;

    static {
        instance = new Singleton2();
        System.out.println("Singleton2单例创建完成...");
    }

    public static Singleton2 getInstance() {
        return instance;
    }

    private Singleton2() {
    }

}
